package com.bsdk.install.device.electricmeter.v1.cmd;

import com.alibaba.fastjson2.JSONObject;
import com.bsdk.common.utils.StringUtils;
import lombok.Getter;
import lombok.NoArgsConstructor;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDateTime;
import java.util.Date;
import java.util.Objects;

/**
 * @projectName: lock
 * @package: com.hlslock.lock.cmd
 * @className: Cmd
 * @author: HansYoung
 * @description: TODO
 * @date: 2023/12/6 14:14
 * @version: 1.0
 */

@NoArgsConstructor
@Getter
public class COMMAND extends Cmd {
    byte[] data = new byte[100];

    public String Meter_Req_Total_Value(String Meter_code)
    {
        int i,j,len;
        byte [] Code = new byte[12];
        j = 0;
        len = Meter_code.length();
        if(len!=12)return "FFFF"; //需要写一下
        Code = toBytes(Meter_code);
        //6 个表号
        for(i = 0;i<6;i++)data[j++] = Code[i];
        data[j++] = 0x11;
        data[j++] = 0x04;
        data[j++] = 0x33;
        data[j++] = 0x33;
        data[j++] = 0x33;
        data[j++] = 0x33;
        return pack_Meter_checksum(data, j);

    }

    //一下是与LORA模块的通讯，协议是不一样的
    public String Moudle_Ping() {
        return "02010078ADFF";
    }
    public String Module_Register() {
        return "02010077ECFF";
    }
    //  FROM GateWay:{ "fMac":"0050C262C21E","cMac":"0000e0357feb","type":"0220","time":"230105121009"}
    public String Module_Register(String gw_mac) {
        int j = 0;
        int i;
        int len;
        byte [] mac = new byte[12];
        j = 0;
        len = gw_mac.length();
        if(len!=12)return "FFFF"; //需要写一下
        mac = toBytes(gw_mac);
        data[j++] = CHILD_SET_MASTER_ADDR_CMD;//注册模块查询
        for(i = 0;i<6;i++)data[j++] = mac[i];
        return pack_crc(data, j);
    }

    public String Module_Get_Register_Info() {
        int j = 0;
        //    private static final byte  CHILD_SET_MASTER_ADDR_CMD = (byte) 0x7E; //注册模块
        //   private static final byte  CHILD_REQ_MASTER_ADDR_CMD = (byte) 0x7F; //查询模块注册

        j = 0;
        data[j++] = CHILD_REQ_MASTER_ADDR_CMD;//注册模块查询
        return pack_crc(data, j);
    }


}
